package oocl.ita.eordering.dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import oocl.ita.eordering.dao.FoodDao;
import oocl.ita.eordering.po.Food;

@Repository
public class FoodDaoImpl implements FoodDao {
	@PersistenceContext(name = "un")
	private EntityManager em;

	@Override
	public List<Food> findFoodByMerchantId(int mId) {
		String jpql="select f from Food f where f.mId=:mId";
		@SuppressWarnings("unchecked")
		List<Food> ls=em.createQuery(jpql)
		.setParameter("mId", mId)
		.getResultList();
		if(ls.isEmpty()) return null;
		else return ls;
	}

}
